package cn.ccit.servers;

import java.util.ArrayList;
import java.util.List;

import cn.ccit.DAO.DishesDAO;
import cn.ccit.DAOImp.DishesDAOimp;
import cn.ccit.entites.Dishes;
import cn.ccit.iservers.IDishesServers;
/**
 * 
 * @类功能说明：  菜品服务类
 * @类修改者：  
 * @修改日期：  
 * @修改说明：  
 * @公司名称：ccit 
 * @作者：wanghao  
 * @创建时间：2016年11月5日 上午12:20:25  
 * @版本：V1.0
 */
public class DishesServers implements IDishesServers {
	private DishesDAO dishDao=null;
	public DishesServers() {
		dishDao=new DishesDAOimp();
	}
	@Override
	public boolean addDishes(Dishes dish) {
		dish.setLastModfiyTime(dish.getCreatTime());
		dish.setLastModfiyUid(dish.getCreatUid());
		dish.setLastModfiyUname(dish.getCreatUname());
		return dishDao.addDishes(dish);
	}

	@Override
	public boolean removeDishes(Dishes dish) {
		return dishDao.removeDishes(dish);
	}

	@Override
	public boolean changeDishesInfo(Dishes dish) {
		return dishDao.changeDishesInfo(dish);
	}

	@Override
	public List<Dishes> getSomeDishes(int start, int limit) {
		return dishDao.getSomeDishes(start, limit);
	}

	@Override
	public Dishes searchDishesByID(int id) {
		return dishDao.searchDishesByID(id);
	}

	@Override
	public Dishes searchDishesByName(String name) {
		return dishDao.searchDishesByName(name);
	}

	@Override
	public List<Dishes> searchDishesByShortFor(String name) {
		String temp=name;
		String reg = "^[A-Za-z]+$";
		if(name.matches(reg)){
			temp=name.toUpperCase();
		}
		List<Dishes> list=dishDao.searchDishesByShortFor(temp);
		if(list!=null){
		  return list;
		}
		return null;
	}
	@Override
	public List<Dishes> searchDishesByKind(String enumName) {
		return dishDao.searchDishesByKind(enumName);
	}

}
